
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.SWT;

public class PointsDisplay
{
    public PointsDisplay(Shell shell, Judicator j)
    {
        myShell = new Shell(shell, SWT.DIALOG_TRIM | SWT.ON_TOP);
        List names = new List(myShell, SWT.BORDER | SWT.V_SCROLL);
        List points = new List(myShell, SWT.BORDER | SWT.V_SCROLL);

        for (Student s : j.students)
        {
            if (s.team != null)
            {
                names.add(s.name);
                points.add(""+getPoints(s,j));
            }
        }

        names.setBounds(10,10,140,600);
        points.setBounds(150,10,50,600);
        myShell.setMinimumSize(210,640);
        myShell.pack();
        myShell.open();
    }

    private double getPoints(Student s, Judicator j)
    {
        double out = 0.0;
        for (Task t : j.tasks) out += getTaskPoints(t,s,j);
        return out;
    }

    private double getTaskPoints(Task t, Student s, Judicator j)
    {
        double out = t.value;
        for (Issue i : s.team.issues)
        {
            if (i.task == t) out += i.value;
        }
        if (out < 0.0) out = 0.0;
        return out;
    }

    private Shell myShell;
}
